//
//  LWFilmController.m
//  豆瓣
//
//  Created by 刘伟 on 16/7/6.
//  Copyright © 2016年 刘伟. All rights reserved.
//

#import "LWFilmController.h"

@interface LWFilmController ()
@property(nonatomic,strong) UIButton* seletebutton;
@property(nonatomic,strong) UIView* line;
@end

@implementation LWFilmController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self settop];
}
-(void)settop{
    UIView *topView = [[UIView alloc]init];
    [self.view addSubview:topView];
    topView.backgroundColor = [UIColor whiteColor];
    topView.x= 0;
    topView.y = 64;
    topView.height = 40;
    topView.width = SCREEN_WIDTH;
    NSArray*a = @[@"正在热映",@"即将上映"];
    for (int i = 0; i<2; i++) {
        UIButton*btn = [[UIButton alloc]init];
        [topView addSubview:btn];
        btn.frame = CGRectMake(i * SCREEN_WIDTH/2.0, 0, SCREEN_WIDTH/2.0, 40);
        [btn setTitle:a[i] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
         [btn setTitleColor:TheThemeColor forState:UIControlStateSelected];
        [btn addTarget:self action:@selector(didclik:) forControlEvents:UIControlEventTouchDown];
        
        btn.tag = i;
        if (i==0) {
            self.seletebutton = btn;
            [self didclik:btn];
      
            
        }
      
    }
    UIScrollView*scrollView = [[UIScrollView alloc]init];
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom);
        make.bottom.equalTo(self.view.mas_bottom).offset(49);
        make.left.right.equalTo(self.view);
    }];
    self.line = [[UIView alloc]init];
    [topView addSubview:self.line];
    self.line.width = SCREEN_WIDTH/2.0;
    self.line.height = 2;
    self.line.y =38;
    self.line.backgroundColor = TheThemeColor;
    
}
-(void)didclik:(UIButton*)btn{
    self.seletebutton.selected =NO;
    btn.selected = YES;
    self.seletebutton = btn;
    self.line.x = btn.tag * SCREEN_WIDTH/2.0;
    


}
-(UIButton *)seletebutton{
    if (_seletebutton == nil) {
        _seletebutton = [UIButton new];
       

    }
    return _seletebutton;
}
@end
